package com.itheima.crm.service;



import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;



import com.itheima.common.utils.Page;
import com.itheima.crm.mapper.GongwenDao;

import com.itheima.crm.pojo.gongwen;
import com.itheima.crm.service.gongwenService;

/**
 * 客户管理
 * 
 * @author lx
 *
 */
@Service
public class gongwenServiceImpl implements gongwenService {

	
	@Autowired
	private GongwenDao gongwendao;
	@Override
	public Page<gongwen> selectgongwen(gongwen vo) {
		Page<gongwen> page = new Page<gongwen>();
		// 每页数
		page.setSize(5);
		vo.setSize(5);
		if (null != vo) {
			// 判断当前页
			if (null != vo.getPage()) {
				page.setPage(vo.getPage());
				vo.setStartRow((vo.getPage() - 1) * vo.getSize());
			}

			// 总条数
			page.setTotal(gongwendao.gongwenCount(vo));
			
			page.setRows(gongwendao.selectgongwen(vo));
		}
		return page;
		
	}

	@Override
	public gongwen selectgongwenById(Integer id) {
		return gongwendao.selectgongwenById(id);
		
	}

	@Override
	public boolean insertgongwen(gongwen gongwen) {
		gongwendao.insertgongwen(gongwen);
		return true;
		
	}

	

	@Override
	public gongwen queryDocByDocId(Integer gwid) {
		gongwen gongwen = gongwendao.queryDocByDocId(gwid);
		return gongwen;
	}
	/**
	 * 根据docId删除文档
	 */
	@Override
	public boolean deleteDocById(Integer id) {
		gongwendao.delete(id);
		return true;
	}


	




}
